<?php namespace App\Http\Controllers\Site;

use App\Http\Controllers\Controller;
use App\Models\Login;
use App\Models\News;
use Illuminate\Support\Facades\DB;

class IndexController extends Controller
{
    //首页
    public function getIndex($id=null)
    {
       $data=DB::table('financial')->whereIn('financial.fproductTypeId',[2,6,7,8])->take(4)->get(); #安心投
        //    print_r($data);
        $bund=DB::table('financial')->whereIn('financial.fproductTypeId',[3])->take(4)->get();
        #项目贷
        $silkbag = DB::table('news')->whereIn('type',[1])->take(4)->get();  #锦囊
        $borrow = DB::table('financial')->whereIn('financial.fproductTypeId',[4])->take(4)->get();  #快速借
        $notice = DB::table('news')->where('type','2')->orderby('updated_at','desc')->first(); #最新公告
        return view( 'site.index',[
            'page'=>'index',
            'data'=>$data,
            'bund'=>$bund,
            'id'=>$id,
            'silkbag'=>$silkbag,
            'borrow' =>$borrow,
            'notice' =>$notice
        ]);
//        echo "首页";
    }
    public function getHelp($id=0)   #帮助中心
    {
        $help = DB::table('question')->paginate(12);;
        return view('site.help',[
            'help' => $help,
            'page'=>'help',
            'appends'=> $id,
        ]);
    }
       

    //法律声明
    public function getLawdeclarction()
    {
        return view('site.law');
//        echo "法律声明";
    }
    //注册协议
    public function getAgreement()
    {
        return view( 'site.agreement');
//        echo "注册协议";
    }
    public function getMP_verify_Jw5Nw32qINm7GRDM()
    {
        return view( 'site.MP_verify_Jw5Nw32qINm7GRDM');
//        echo "注册协议";
    }


    //销售排行页
    public function getSalesrank()
    {
        echo "销售排行";
    }

    //产品列表页
    public function getProductlist()
    {
        echo "产品列表";
    }

    //产品类目
    public function getProductsort()
    {
        echo "产品类目";
    }

    //产品详情
    public function getProductdetails()
    {
        echo "产品详情";
    }


    //联系我们页
    public function getContactus()
    {
        echo "联系我们";
    }
    public function getAbout()  #关于我们
    {
        return view('site.about');
    }
    public function getTeam()   #团队介绍
    {
        return view('site.team');
    }
    public function getFriendship()
    {
        return view('site.friendship');
    }

    //产品搜索
    public function getSerch()
    {
        echo "产品搜索";
    }

    //购买
    public function getBuying()
    {
        echo "购买";
    }

    //交易完成
    public function getPromptcompletion()
    {
        echo "完成提示";
    }

    public function getTest()
    {
//        $owner = new Role();
//        $owner->name = 'owner';
//        $owner->display_name='Project Owner';
//        $owner->description = 'User is the owner of a given project';
//        $owner->save();
//
//        $admin = new Role();
//        $admin->name = 'admin';
//        $admin->display_name = 'User Administrator';
//        $admin->description = 'User is allowed to manage and edit other users';
//        $admin->save();
//
//        $user = new User();
//        $user->name = 'michele';
//        $user->save();
//        $user = User::where('name', '=', 'michele')->first();
//
//
    }
}